package com.lekang.le.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lekang.common.annotation.Log;
import com.lekang.common.core.controller.BaseController;
import com.lekang.common.core.domain.AjaxResult;
import com.lekang.common.enums.BusinessType;
import com.lekang.le.domain.PendingTasks;
import com.lekang.le.service.IPendingTasksService;
import com.lekang.common.utils.poi.ExcelUtil;
import com.lekang.common.core.page.TableDataInfo;

/**
 * 待办任务Controller
 * 
 * @author szh
 * @date 2025-10-21
 */
@RestController
@RequestMapping("/le/pendingTasks")
public class PendingTasksController extends BaseController
{
    @Autowired
    private IPendingTasksService pendingTasksService;

    /**
     * 查询待办任务列表
     */
    @PreAuthorize("@ss.hasPermi('le:pendingTasks:list')")
    @GetMapping("/list")
    public TableDataInfo list(PendingTasks pendingTasks)
    {
        startPage();
        List<PendingTasks> list = pendingTasksService.selectPendingTasksList(pendingTasks);
        return getDataTable(list);
    }

    /**
     * 导出待办任务列表
     */
    @PreAuthorize("@ss.hasPermi('le:pendingTasks:export')")
    @Log(title = "待办任务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PendingTasks pendingTasks)
    {
        List<PendingTasks> list = pendingTasksService.selectPendingTasksList(pendingTasks);
        ExcelUtil<PendingTasks> util = new ExcelUtil<PendingTasks>(PendingTasks.class);
        util.exportExcel(response, list, "待办任务数据");
    }

    /**
     * 获取待办任务详细信息
     */
    @PreAuthorize("@ss.hasPermi('le:pendingTasks:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pendingTasksService.selectPendingTasksById(id));
    }

    /**
     * 新增待办任务
     */
    @PreAuthorize("@ss.hasPermi('le:pendingTasks:add')")
    @Log(title = "待办任务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PendingTasks pendingTasks)
    {
        return toAjax(pendingTasksService.insertPendingTasks(pendingTasks));
    }
    @PreAuthorize("@ss.hasPermi('le:pendingTasks:add')")
    @Log(title = "待办任务", businessType = BusinessType.INSERT)
    @PostMapping("/addSZH")
    public AjaxResult addSZH(@RequestBody PendingTasks pendingTasks)
    {
        return toAjax(pendingTasksService.insertPendingTasksSZH(pendingTasks));
    }

    /**
     * 修改待办任务
     */
    @PreAuthorize("@ss.hasPermi('le:pendingTasks:edit')")
    @Log(title = "待办任务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PendingTasks pendingTasks)
    {
        return toAjax(pendingTasksService.updatePendingTasks(pendingTasks));
    }

    /**
     * 删除待办任务
     */
    @PreAuthorize("@ss.hasPermi('le:pendingTasks:remove')")
    @Log(title = "待办任务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pendingTasksService.deletePendingTasksByIds(ids));
    }
}
